﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DrSoftsFrame;
//using System.Web.SessionState;
using System.Web;
using System.Data;
using PreeRegisterModel;
using System.Configuration;

namespace PreeRegisterBLL
{
    public class VariableBLL
    {
        private static int _iWorkPlanTypeID;

        private static int _iYYDaySpan;

        private static int _iBlackPreeCount;

        //加密方式  liujia150913   1.联康  2.非联康
        private static int _EncryptType;

        /// <summary>
        /// 类型
        /// </summary>
        public static int iWorkPlanTypeID
        {
            #region
            get
            {
                return (int)_iWorkPlanTypeID;
            }
            set
            {
                _iWorkPlanTypeID = value;
            }
            #endregion
        }

        /// <summary>
        /// 预约天数
        /// </summary>
        public static int iYYDaySpan
        {
            #region
            get
            {
                //增加视图是否为空判断  liujia150813
                DataView dvType = CommonBLL.GetDataView("OPDWorkPlanType");
                if (dvType == null)
                {
                    string cvalue = CommonBLL.GetValueFromSystemSet("YYDaySpan");
                    _iYYDaySpan = Common.ToInt(cvalue);
                    return (int)_iYYDaySpan;
                }
                dvType.RowFilter = "iWorkPlanTypeID=" + iWorkPlanTypeID;
                if (dvType.Count > 0 && Common.ToInt(dvType[0]["iPreeDay"]) > 0)
                {
                    _iYYDaySpan = Common.ToInt(dvType[0]["iPreeDay"]);
                }
                else
                {
                    string cvalue = CommonBLL.GetValueFromSystemSet("YYDaySpan");
                    _iYYDaySpan = Common.ToInt(cvalue);
                }

                return (int)_iYYDaySpan;
            }
            set
            {
                _iYYDaySpan = value;
            }
            #endregion
        }

        /// <summary>
        /// 时间段挂号配置
        /// </summary>
        public static bool bPreTime
        {
            #region
            get
            {
                //object ret = System.Web.HttpContext.Current.Session["PreTime"];
                //if (ret == null)
                //{
                bool pretime;
                if (CommonBLL.GetValueFromSystemSet("sPreTime").Trim() == "1")//时间段挂号
                    pretime = true;
                else
                    pretime = false;
                //}
                return pretime;
            }
            set
            {
                //System.Web.HttpContext.Current.Session["PreTime"] = value;
            }
            #endregion
        }

        /// <summary>
        /// 预约诊疗平台住院服务URL
        /// </summary>
        public static string RDSP_IPAdress_INHOSPService
        {
            get
            {
                string IPAdress = CommonBLL.GetConfig("RDSP_IPAdress_INHOSPService");
                return IPAdress;
            }
            set
            {

            }
        }

        /// <summary>
        /// 医院编号
        /// </summary>
        public static string HospitalId
        {
            get
            {
                //DataView dv = Common.GetDataView("pubDictUnit", false, DrSoftsFrame.Servers.DbParms.DbConnType.ClinicDb);
                //return dv[0]["nUnitCode"].ToString();
                string Interval = CommonBLL.GetConfig("hosCode");
                return Interval;
            }
            set
            {

            }
        }

        /// <summary>
        /// 是否分时 1不分时 2分时
        /// </summary>
        public static string atype
        {
            get
            {
                //DataView dv = Common.GetDataView("pubDictUnit", false, DrSoftsFrame.Servers.DbParms.DbConnType.ClinicDb);
                //return dv[0]["nUinitName"].ToString();
                string Interval = CommonBLL.GetConfig("atype");
                return Interval;
            }
            set
            {

            }
        }

        /// <summary>
        /// 身份标识
        /// </summary>
        public static string ApplicationId
        {
            #region
            get
            {
                return "0001";
            }
            set
            {
                //System.Web.HttpContext.Current.Session["ApplicationId"] = value;
            }
            #endregion
        }

        /// <summary>
        /// 爽约次数
        /// </summary>
        public static int iBlackPreeCount
        {
            #region
            get
            {
                object ret = _iBlackPreeCount;
                //增加判断为0时的情况  liujia151125
                if (ret == null || Convert.ToInt16(ret) == 0)
                {
                    _iBlackPreeCount = 3;
                }
                return (int)_iBlackPreeCount;
            }
            set
            {
                _iBlackPreeCount = value;
            }
            #endregion
        }

        /// <summary>
        /// 是否同煤版本  liujia150812
        /// </summary>
        public static bool IFTmkyy
        {
            #region
            get
            {
                bool Tmkyy;
                if (ConfigurationManager.AppSettings["IFTmkyy"].ToString().Trim() == "1")
                    Tmkyy = true;
                else
                    Tmkyy = false;
                return Tmkyy;
            }
            set
            {
                //System.Web.HttpContext.Current.Session["PreTime"] = value;
            }
            #endregion
        }

        /// <summary>
        /// 初始化同步排班号源天数  liujia150828
        /// </summary>
        public static string SynWorkDay
        {
            #region
            get
            {
                string Interval = ConfigurationManager.AppSettings["SynWorkDay"].ToString().Trim();
                if (Interval == "")
                {
                    Interval = "15";
                }
                return Interval;
            }
            set
            {
                //System.Web.HttpContext.Current.Session["PreTime"] = value;
            }
            #endregion
        }

        /// <summary>
        /// 加密方式  liujia150913
        /// </summary>
        public static int EncryptType
        {
            #region
            get
            {
                return (int)_EncryptType;
            }
            set
            {
                _EncryptType = value;
            }
            #endregion
        }

        /// <summary>
        /// 获取头信息
        /// </summary>
        /// <returns></returns>
        public static Head GetHead()
        {
            try
            {
                Head myhead = new Head();
                myhead.token = "7fa7d90b11cc173c15e5b474459aa661";
                myhead.version = "1.0";
                myhead.fromtype = "wd1cx80ad3hj";
                //myhead.fromtype = "UH_RDSP_WWW";
                myhead.sessionid = "12333344444";
                myhead.time = "1432091844";
                return myhead;
            }
            catch (Exception err)
            {

                throw;
            }
        }

        /// <summary>
        /// 区域编码  liujia150917
        /// </summary>
        public static string areaCode
        {
            #region
            get
            {
                string code = ConfigurationManager.AppSettings["areaCode"].ToString().Trim();
                if (code == "")
                {
                    code = "A";
                }
                return code;
            }
            set
            {
                //System.Web.HttpContext.Current.Session["PreTime"] = value;
            }
            #endregion
        }

        /// <summary>
        /// 医院编码  liujia150917
        /// </summary>
        public static string hosCode
        {
            #region
            get
            {
                string code = ConfigurationManager.AppSettings["hosCode"].ToString().Trim();
                if (code == "")
                {
                    code = "130";
                }
                return code;
            }
            set
            {
                //System.Web.HttpContext.Current.Session["PreTime"] = value;
            }
            #endregion
        }


        /// <summary>
        /// 是否绑定诊疗卡模式  liujia151120
        /// </summary>
        public static bool IFBindZLK
        {
            #region
            get
            {
                bool BindZLK;
                if (ConfigurationManager.AppSettings["IFBindZLK"].ToString().Trim() == "1")
                    BindZLK = true;
                else
                    BindZLK = false;
                return BindZLK;
            }
            set
            {
                //System.Web.HttpContext.Current.Session["PreTime"] = value;
            }
            #endregion
        }

        /// <summary>
        /// 诊疗卡医院编码  liujia151120
        /// 儿童医院:1001 太铁:1002 肿瘤医院:1003  山西大医院:1004 山大一院:1005 省人民:1006 山大二院:1008  眼科医院:1009;晋中人民:1010 长治妇幼:1011 
        /// </summary>
        public static string HosNamey
        {
            #region
            get
            {
                string hosNamey = ConfigurationManager.AppSettings["HosNamey"].ToString().Trim();
                if (hosNamey == "")
                {
                    hosNamey = "1004";
                }
                return hosNamey;
            }
            set
            {
                //System.Web.HttpContext.Current.Session["PreTime"] = value;
            }
            #endregion
        }

    }
}
